#include <iostream>
#include <algorithm>	
#include <vector>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <limits.h>
#include "file.hpp"
#include "fileiterator.hpp"
#include "filemerger.hpp"
#include "filesorter.hpp"

extern int errno;
//sort made via temporary files /tmp
//actually it's rather dangerous, because lack of memory in /tmp you may crash your os
int main(int argc, char *argv[]) {
	if (argc != 3) {
		errno = EINVAL;
		perror("lack of arguments");
		exit(EXIT_FAILURE);
	}
	FileSorter sorter = FileSorter(argv[1], argv[2]);
	sorter.sort();
	std::cout << "Sorting finished. Maybe even successfuly." << std::endl;
	return 0;
}
